var t = getApp();

Page({
    data: {
        vid: "",
        videoTapPlay: !1,
        loadOne: !1
    },
    onLoad: function(t) {
        t.id && this.setData({
            vid: t.id
        });
    },
    onReady: function() {},
    onShow: function() {
        this.loadOne = !1, this.getData(), this.getinformation();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    currtime: function(e) {
        var a = e.detail.currentTime.toFixed(1), i = e.detail.duration.toFixed(1);
        if (console.log(a, i), console.log(Math.floor(a / i * 100)), a / i * 100 >= this.data.percentage && !this.data.loadOne) {
            this.data.loadOne = !0;
            var o = t.getNetAddresss("plugin.agent-qa.api.video.watch-video");
            t._postNetWork({
                url: o,
                data: {
                    video_id: this.data.vid
                },
                success: function(t) {
                    var e = t.data;
                    1 != e.result && wx.showToast({
                        title: e.msg,
                        icon: "none"
                    });
                },
                fail: function(t) {
                    wx.showToast({
                        title: t.msg,
                        icon: "none"
                    });
                }
            });
        }
    },
    getinformation: function() {
        try {
            var t = wx.getSystemInfoSync().windowHeight;
            this.data.screeheight = t;
        } catch (t) {}
    },
    tapPlay: function(t) {
        console.log(t);
        var e = this, a = wx.createSelectorQuery();
        a.select("#pic").boundingClientRect(), a.exec(function(t) {
            console.log(t[0].height);
            var a = e.data.screeheight;
            if (t[0] && t[0].height) {
                var i = t[0].height;
                console.log(i > Math.ceil(a * (7 / 8))), i > Math.ceil(a * (7 / 8)) ? e.setData({
                    minStyle: !1
                }) : e.setData({
                    minStyle: !0
                });
            } else e.setData({
                minStyle: !0
            });
        }), this.setData({
            videoTapPlay: !0
        });
    },
    getData: function() {
        var e = this, a = t.getNetAddresss("plugin.agent-qa.api.video.get-info");
        t._postNetWork({
            url: a,
            data: {
                video_id: e.data.vid
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    videoSrc: a.data.url,
                    fmimg: a.data.image,
                    percentage: a.data.percentage
                }), wx.setNavigationBarTitle({
                    title: a.data.title
                })) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                wx.showToast({
                    title: t.msg,
                    icon: "none"
                });
            }
        });
    }
});